package cn.tlb.upload;

/**
 * Created by 汤林冰 on 2015/12/25 15:15.
 */
public class Input {
    /**表单类型,支持 {@link Type#TEXT}, {@link Type#FILE}, 默认{@link Type#TEXT}*/
    public Type type = Type.TEXT;

    public String name = "";

    public String value = "";

    public String filename = "";

    public static Input newTextInput(String name, String value) {
        Input input = new Input();
        input.name = name;
        input.value = value;
        return input;
    }

    public static Input newFileInput(String name, String filename) {
        Input input = new Input();
        input.name = name;
        input.filename = filename;
        input.type = Type.FILE;
        return input;
    }

    public static enum Type{
        TEXT{
            @Override
            String getString() {
                return "text";
            }
        },

        FILE{
            @Override
            String getString() {
                return "file";
            }
        };

        abstract String getString();
    }
}
